import { app } from "../app";
import { testProxy } from "../http/api/proxy";
import { closeProxy, getProxyAgent, ipProxy, startProxy } from "../utils/proxy";

const proxyRouter=()=>{
   
    // 启动代理
    app.get('/proxy/start',async (req, res) => {
       await startProxy();
       return res.send(ipProxy)
    })

    // 测试代理a
     app.get('/proxy/test',async (req, res) => {
      const result= await testProxy(await getProxyAgent());
       return res.send( result?.data||"无代理")
    })

     // 关闭代理
    app.get('/proxy/close',async (req, res) => {
       await closeProxy();
       return res.send("关闭代理成功")
    })
}

export default proxyRouter;